package com.unibeta.cloudtest.springboot.config;

import java.util.Date;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.lang.time.DateFormatUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;

@ConfigurationProperties(prefix = "cloudtest")
public class CloudTestProperties {
	@Value("${endpoint:/restful/cloudtest/*}")
	String endpoint;
	@Value("${enabled:true}")
	String enabled = "true";
	@Value("${disabled-on-active-profiles:prod,live,prd,pro}")
	String[] disabledOnActiveProfiles;
	@Value("${starter-file:cloudtest/starter.xml}")
	String starterFile;
	@Value("${access-token-name:}") 
	String accessTokenName;
	@Value("${aes-key:6c0744970b5a369b}") 
	String aesKey;
	@Value("${password:}") 
	String password;

	public String getEndpoint() {
		return endpoint;
	}

	public void setEndpoint(String endpoint) {
		this.endpoint = endpoint;
	}

	public String getEnabled() {
		return enabled;
	}

	public void setEnabled(String enabled) {
		this.enabled = enabled;
	}

	public String[] getDisabledOnActiveProfiles() {
		return disabledOnActiveProfiles;
	}

	public void setDisabledOnActiveProfiles(String[] disabledOnActiveProfiles) {
		this.disabledOnActiveProfiles = disabledOnActiveProfiles;
	}

	public String getStarterFile() {
		return starterFile;
	}

	public void setStarterFile(String starterFile) {
		this.starterFile = starterFile;
	}

	public String getAccessTokenName() {
		return accessTokenName;
	}

	public void setAccessTokenName(String accessTokenName) {
		this.accessTokenName = accessTokenName;
	}

	public String getAesKey() {
		return aesKey;
	}

	public void setAesKey(String aesKey) {
		this.aesKey = aesKey;
	}

	public String getPassword() {
		if(StringUtils.isBlank(password)) {
			password = DateFormatUtils.format(new Date(), "yyyyMM");
		}
		return password;
	}

	public void setPassword(String password) {
		this.password = password;
	}
}
